package com.gxa.controller;

import com.gxa.common.LayR;
import com.gxa.common.R;
import com.gxa.param.MyTableParam;
import com.gxa.pojo.Develop;
import com.gxa.service.customerService;
import com.gxa.service.developService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/develop")
public class developController {
    @Autowired
    private developService service;



    @GetMapping("/list/page")
    public String develop(){
        return "develop/customer-develop";
    }

    @PostMapping("/list/data")
    @ResponseBody
    public LayR list(MyTableParam param){

        return service.list(param);
    }



    @PostMapping("/deleteOne")
    @ResponseBody
    public R deleteOne(Integer id){

        return service.deleteOne(id);
    }

    @PostMapping("/delete")
    @ResponseBody
    public R delete(@RequestParam("ids[]") String[] ids){
        return service.deleteAll(ids);
    }

    @GetMapping("/add/page")
    public String addPage(){
        return "develop/develop-add";
    }

    @PostMapping("/add/do")
    @ResponseBody
    public R add(Develop develop, HttpSession session){

        return service.add(develop,session);

    }
    @GetMapping("/edit/page")
    public String editPage(Integer id, Model model){

        model.addAttribute("developId", id);

        return "develop/develop-edit";

    }


    @PostMapping("/detail")
    @ResponseBody
    public R detail(Integer id){
        return service.findById(id);
    }

    @PostMapping("/edit/do")
    @ResponseBody
    public R edit(Develop develop){

        return service.edit(develop);
    }

}
